{% extends "layout.html" %}
{% block content %}
<div class="container">
    <div class="row d-flex justify-content-between">
        <div class="col-6">
            <h1>Request status</h1>
            <p>Creation date: <b>{{ request.created_at | datetimeformat }}</b></p>
            <p>Service concerned: <b>{{ request.service.name }}</b></p>
            <p>Checked: <b>{{ 'Yes' if request.checked else 'No'}}</b></p>
            <p>Notification sent: <b>{{ 'Yes' if request.notification_sent else 'No'}}</b></p>
        </div>
        <div class="col-6">
            <span class="float-right">
                <div class="dropdown">
                    <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        Actions
                    </button>
                    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                        <a class="dropdown-item" href="{{ url_for('admin_bp.send_request_notification', request_id=request.id) }}">Re-send notification</a>
                        <a class="dropdown-item" href="{{ url_for('admin_bp.mark_as_unchecked', request_id=request.id) }}">Mark as {% if request.checked %}un{% endif %}checked</a>
                        <a class="dropdown-item" href="{{ url_for('admin_bp.delete_request', request_id=request.id) }}" onclick="return confirm('You are going to delete this request.');">Delete</a>
                    </div>
                </div>
            </span>
        </div>
    </div>

    <br />

    <div class="row">
        <div class="col">
            <h1>Requester</h1>
            <p>Email: <b>{{ request.email }}</b></p>
            <p>Firstname, Lastname: <b>{{ request.firstname }}, {{ request.lastname }}</b></p>
        </div>
    </div>

    <br />

    <div class="row">
        <div class="col">
            <h1>Required informations</h1>
            <table class="table">
                <tbody>
                    {% for info in request.service.required_informations %}
                    <tr>
                        <th scope="row">{{ info['name'] }}</th>
                        {% if request.required_informations[info['name']] %}
                            {% if 'image' in info['mimetype'] %}
                              <td><img src="{{ request.required_informations[info['name']] }}" width='200px' /></td>
                            {% elif 'application/pgp-keys' in info['mimetype'] or 'textarea' in info['type'] %}
                                <td><pre><code>{{ request.required_informations[info['name']] }}</code></pre></td>
                            {% else %}
                              <td>{{ request.required_informations[info['name']] }}</td>
                            {% endif %}
                        {% else %}
                            <td><b>Not provided by requester.</b></td>
                        {% endif %}
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

</div><!-- /.container -->
<script>
$(document).ready(function() {
});
</script>
{% endblock %}
